home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Sample.bin
/
LinkList.java
< prev
next >
Wrap
Text File
|
1998-11-01
|
1KB
|
63 lines
/**
* A simple one-directional external linked list class.
*/
public class LinkList extends Object
{
private LinkList therest;
private Object thevalue;
public LinkList(Object obj)
{
therest = null;
thevalue = obj;
//{{INIT_CONTROLS
//}}
}
/**
* Create a new list node; insert it at the head of the list. Return the list.
*/
public LinkList cons(Object obj)
{
LinkList newnode = new LinkList(obj);
newnode.thevalue = thevalue;
newnode.therest = therest;
therest = newnode;
thevalue = obj;
return this;
}
/**
* The object owned by the list node
*/
public Object value()
{
return thevalue;
}
/**
* The remainder of the list
*/
public LinkList rest()
{
return therest;
}
/**
* Swap the values of a and b.
*/
public static void swapValues(LinkList a, LinkList b)
{
Object save = a.thevalue;
a.thevalue = b.thevalue;
b.thevalue = save;
}
//{{DECLARE_CONTROLS
//}}
}